<?php 

$max_width = 75;


$directory = "{$_SERVER["DOCUMENT_ROOT"]}/{$_REQUEST["folder"]}";

   // create a handler to the directory
    $dirhandler = opendir($directory);
 
    // read all the files from directory
    $nofiles=0;
    while ($file = readdir($dirhandler)) {
 
        // if $file isn't this directory or its parent 
        //add to the $files array
        if ($file != '.' && $file != '..')
        {	
			$files[$nofiles]=$file;    
			$nofiles++;            
        }   
    }

    

    foreach ($files as $img=>$value) {
    	$src = "{$_REQUEST["folder"]}/{$value}";
    	
    	list($width, $height, $type, $attr) = getimagesize("{$_SERVER["DOCUMENT_ROOT"]}{$src}");
    	
    	if ($width>=$max_width) $width = $max_width;
    	echo "<div><img  style=width:{$width}px src=\"{$src}\" onclick=\"javascript:insert_gallery_image('{$src}');\"></div>";
    }


?>
<script type="text/javascript">
add_css("/modules/gallery/css/default.css");
add_js("/modules/gallery/gallery.js","0.01");
</script>